from flask import Flask
from flask_cors import CORS
from config.load_yaml import load_config
from flask_moudle.bp.upload_file_bp import upload_file_bp
from flask_moudle.bp.image_analysis_bp import analysis_bp
from flask_moudle.service.predict import seg_predict


def create_app():
    app = Flask(__name__)
    bps = [analysis_bp, upload_file_bp]
    # app.register_error_handler(Exception, handle_exception)
    CORS(app)
    config = load_config()
    app.config['MAX_CONTENT_LENGTH'] = config['file']['upload_max_size'] * 1024
    for bp in bps:
        app.register_blueprint(bp)
    return app


if __name__ == '__main__':
    app = create_app()
    app.run(host='0.0.0.0', port=5000, debug=True)
